#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2021/7/26 16:17
# @Author  : ldh

from basic.device.Android import Android

class AGXSearchPage(Android):
    searchBtm="cn.cloudbae.loveguangxi:id/search_bg" #首页搜索
    etSearch="cn.cloudbae.loveguangxi:id/etSearch" #搜索框
    openApp="cn.cloudbae.loveguangxi:id/open_app" #搜索结果，应用【打开】按钮
    emptyView="cn.cloudbae.loveguangxi:id/emptyView_hint_txt" #搜索结果为空


    #打开搜索页面
    @classmethod
    def openSearch(cls):
         cls.poco(cls.searchBtm).click()

    #将光标移出
    @classmethod
    def moveOut(cls):
        cls.poco(text="热门搜索").click()

    #输入搜索关键字
    @classmethod
    def imputSearch(cls,text):
        cls.poco(cls.etSearch).set_text(text)


    # #搜索热门应用
    # @classmethod
    # def searchHotApp(cls):
    #     cls.poco(text="司法公正").click()

    #判断搜索结果是否为空
    @classmethod
    def ifEmpty(cls):
        if cls.poco(cls.emptyView).wait(5).exists():
            return True
        else:
            return False

    #打开搜索结果
    @classmethod
    def SearchDetail(cls):
        cls.poco(cls.openApp)[0].click()
        print("查看搜索结果详情")